
from _spice_path import spice_path

def _lowerlimit(spiceref,motorname):
    motorglobal=spiceref.GetVIReference(spice_path + '\\common\\globals\\motor_globals.vi')
    searchvi=spiceref.GetVIReference(spice_path + '\\common\\Utilities\\device_utilities\\SearchMotorListByNameOrAlias.vi')
    parnames='Motor','Device Index','Motor Index','found?'
    parvalues=motorname,0,0,0
    searchnames,searchvalues=searchvi.Call(parnames,parvalues)
    motorindexvalue=searchvalues[2]
    tolvalues=motorglobal.GetControlValue('User Lower Limit')
    tolerance=tolvalues[motorindexvalue]
    return tolerance
